package frame.options.virtualNetworks.create;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentListener;

import model.components.links.factory.VirtualLinksFactory;
import model.components.networks.factory.VirtualNetworksFactory;
import model.components.nodes.factory.VirtualNodesFactory;

@SuppressWarnings("serial")
public class CreateVirtualNetworksSelectPanel extends JPanel 
{
	private JLabel networksNumberLabel;
	public JLabel getNetworksNumberLabel(){ return networksNumberLabel; }
	public void setNetworksNumberLabel( JLabel networksNumberLabel ){ this.networksNumberLabel = networksNumberLabel; }
	
	private JTextField networksNumberTextField;
	public JTextField getNetworksNumberTextField(){ return networksNumberTextField; }
	public void setNetworksNumberTextField( JTextField networksNumberTextField ){ this.networksNumberTextField = networksNumberTextField; }

	private JLabel windowTimeUnitsNumberLabel;
    public JLabel getWindowTimeUnitsNumberLabel(){ return windowTimeUnitsNumberLabel; }
	public void setWindowTimeUnitsNumberLabel( JLabel windowTimeUnitsNumberLabel ){ this.windowTimeUnitsNumberLabel = windowTimeUnitsNumberLabel; }
	
	private JTextField windowTimeUnitsNumberTextField;
    public JTextField getWindowTimeUnitsNumberTextField(){ return windowTimeUnitsNumberTextField; }
	public void setWindowTimeUnitsNumberTextField( JTextField windowTimeUnitsNumberTextField ){ this.windowTimeUnitsNumberTextField = windowTimeUnitsNumberTextField; }

	private JLabel poissonArrivesLabel;
    public JLabel getPoissonArrivesLabel(){ return poissonArrivesLabel; }
	public void setPoissonArrivesLabel( JLabel poissonArrivesLabel ){ this.poissonArrivesLabel = poissonArrivesLabel; }
	
	private JTextField poissonArrivesTextField;
    public JTextField getPoissonArrivesTextField(){ return poissonArrivesTextField; }
	public void setPoissonArrivesTextField( JTextField poissonArrivesTextField ){ this.poissonArrivesTextField = poissonArrivesTextField; }

	private JLabel exponentialLifetimeLabel;
    public JLabel getExponentialLifetimeLabel(){ return exponentialLifetimeLabel; }
	public void setExponentialLifetimeLabel( JLabel exponentialLifetimeLabel ){ this.exponentialLifetimeLabel = exponentialLifetimeLabel; }
	
	private JTextField exponentialLifetimeTextField;
    public JTextField getExponentialLifetimeTextField(){ return exponentialLifetimeTextField; }
	public void setExponentialLifetimeTextField( JTextField exponentialLifetimeTextField ){ this.exponentialLifetimeTextField = exponentialLifetimeTextField; }

	private JLabel nodesNumberLabel;
	public JLabel getNodesNumberLabel(){ return nodesNumberLabel; }
	public void setNodesNumberLabel( JLabel nodesNumberLabel ){ this.nodesNumberLabel = nodesNumberLabel; }
	
	private JTextField minNodesNumberTextField;
	public JTextField getMinNodesNumberTextField(){ return minNodesNumberTextField; }
	public void setMinNodesNumberTextField( JTextField minNodesNumberTextField ){ this.minNodesNumberTextField = minNodesNumberTextField; }
	
	private JTextField maxNodesNumberTextField;
	public JTextField getMaxNodesNumberTextField(){ return maxNodesNumberTextField; }
	public void setMaxNodesNumberTextField( JTextField maxNodesNumberTextField ){ this.maxNodesNumberTextField = maxNodesNumberTextField; }
	
	private JLabel nodeTypesPercentagesLabel;
	public JLabel getNodeTypesPercentagesLabel(){ return nodeTypesPercentagesLabel; }
	public void setNodeTypesPercentagesLabel( JLabel nodeTypesPercentagesLabel ){ this.nodeTypesPercentagesLabel = nodeTypesPercentagesLabel; }
	
	private JTextField routersPercentageTextField;
	public JTextField getRoutersPercentageTextField(){ return routersPercentageTextField; }
	public void setRoutersPercentageTextField( JTextField routersPercentageTextField ){ this.routersPercentageTextField = routersPercentageTextField; }

	private JTextField switchesPercentageTextField;
	public JTextField getSwitchesPercentageTextField(){ return switchesPercentageTextField; }
	public void setSwitchesPercentageTextField( JTextField switchesPercentageTextField ){ this.switchesPercentageTextField = switchesPercentageTextField; }
	
	private JTextField serversPercentageTextField;
	public JTextField getServersPercentageTextField(){ return serversPercentageTextField; }
	public void setServersPercentageTextField( JTextField serversPercentageTextField ){ this.serversPercentageTextField = serversPercentageTextField; }

	private JLabel operatingSystemsLabel;
	public JLabel getOperatingSystemsLabel(){ return operatingSystemsLabel; }
	public void setOperatingSystemsLabel( JLabel operatingSystemsLabel ){ this.operatingSystemsLabel = operatingSystemsLabel; }
	
	private JTextField linuxPercentageTextField;
	public JTextField getLinuxPercentageTextField(){ return linuxPercentageTextField; }
	public void setLinuxPercentageTextField( JTextField linuxPercentageTextField ){ this.linuxPercentageTextField = linuxPercentageTextField; }

	private JTextField windowsPercentageTextField;
	public JTextField getWindowsPercentageTextField(){ return windowsPercentageTextField; }
	public void setWindowsPercentageTextField( JTextField windowsPercentageTextField ){ this.windowsPercentageTextField = windowsPercentageTextField; }
	
	private JTextField solarisPercentageTextField;
	public JTextField getSolarisPercentageTextField(){ return solarisPercentageTextField; }
	public void setSolarisPercentageTextField( JTextField solarisPercentageTextField ){ this.solarisPercentageTextField = solarisPercentageTextField; }

	private JTextField androidPercentageTextField;
	public JTextField getAndroidPercentageTextField(){ return androidPercentageTextField; }
	public void setAndroidPercentageTextField( JTextField androidPercentageTextField ){ this.androidPercentageTextField = androidPercentageTextField; }

	private JLabel virtualEnvironmentsLabel;
	public JLabel getVirtualEnvironmentsLabel(){ return virtualEnvironmentsLabel; }
	public void setVirtualEnvironmentsLabel( JLabel virtualEnvironmentsLabel ){ this.virtualEnvironmentsLabel = virtualEnvironmentsLabel; }
	
	private JTextField vmWarePercentageTextField;
	public JTextField getVmWarePercentageTextField(){ return vmWarePercentageTextField; }
	public void setVmWarePercentageTextField( JTextField vmWarePercentageTextField ){ this.vmWarePercentageTextField = vmWarePercentageTextField; }

	private JTextField xenPercentageTextField;
	public JTextField getXenPercentageTextField(){ return xenPercentageTextField; }
	public void setXenPercentageTextField( JTextField xenPercentageTextField ){ this.xenPercentageTextField = xenPercentageTextField; }
	
	private JTextField kvmPercentageTextField;
	public JTextField getKvmPercentageTextField(){ return kvmPercentageTextField; }
	public void setKvmPercentageTextField( JTextField kvmPercentageTextField ){ this.kvmPercentageTextField = kvmPercentageTextField; }
	
	private JTextField umlPercentageTextField;
	public JTextField getUmlPercentageTextField(){ return umlPercentageTextField; }
	public void setUmlPercentageTextField( JTextField umlPercentageTextField ){ this.umlPercentageTextField = umlPercentageTextField; }
	
	private JRadioButton linksNumberPercentageRadioButton;
	public JRadioButton getLinksNumberPercentageRadioButton(){ return linksNumberPercentageRadioButton; }
	public void setLinksNumberPercentageRadioButton( JRadioButton linksNumberPercentageRadioButton ){ this.linksNumberPercentageRadioButton = linksNumberPercentageRadioButton; }

	private JTextField linksNumberPercentageTextField;
	public JTextField getLinksNumberPercentageTextField(){ return linksNumberPercentageTextField; }
	public void setLinksNumberPercentageTextField( JTextField linksNumberPercentageTextField ){ this.linksNumberPercentageTextField = linksNumberPercentageTextField; }
	
	private JRadioButton linksNumberRangeRadioButton;
	public JRadioButton getLinksNumberRangeRadioButton(){ return linksNumberRangeRadioButton; }
	public void setLinksNumberRangeRadioButton( JRadioButton linksNumberRangeRadioButton) { this.linksNumberRangeRadioButton = linksNumberRangeRadioButton; }
		
	private JTextField minLinksNumberTextField;
	public JTextField getMinLinksNumberTextField(){ return minLinksNumberTextField; }
	public void setMinLinksNumberTextField( JTextField minLinksNumberTextField ){ this.minLinksNumberTextField = minLinksNumberTextField; }

	private JTextField maxLinksNumberTextField;
	public JTextField getMaxLinksNumberTextField(){ return maxLinksNumberTextField; }
	public void setMaxLinksNumberTextField( JTextField maxLinksNumberTextField ){ this.maxLinksNumberTextField = maxLinksNumberTextField; }
	
	private JLabel linkTypesPercentagesLabel;
	public JLabel getLinkTypesPercentagesLabel(){ return linkTypesPercentagesLabel; }
	public void setLinkTypesPercentagesLabel( JLabel linkTypesPercentagesLabel ){ this.linkTypesPercentagesLabel = linkTypesPercentagesLabel; }
	
	private JTextField vlanPercentageTextField;
	public JTextField getVlanPercentageTextField(){ return vlanPercentageTextField; }
	public void setVlanPercentageTextField( JTextField vlanPercentageTextField ){ this.vlanPercentageTextField = vlanPercentageTextField; }

	private JTextField sonetPercentageTextField;
	public JTextField getSonetPercentageTextField(){ return sonetPercentageTextField; }
	public void setSonetPercentageTextField( JTextField sonetPercentageTextField ){ this.sonetPercentageTextField = sonetPercentageTextField; }
	
	private JTextField eight0211PercentageTextField;
	public JTextField getEight0211PercentageTextField(){ return eight0211PercentageTextField; }
	public void setEight0211PercentageTextField( JTextField eight0211PercentageTextField ){ this.eight0211PercentageTextField = eight0211PercentageTextField; }
	
	private JLabel cpuLabel;
	public JLabel getCpuLabel(){ return cpuLabel; }
	public void setCpuLabel( JLabel cpuLabel ){ this.cpuLabel = cpuLabel; }
	
	private JTextField minCpuTextField;
	public JTextField getMinCpuTextField(){ return minCpuTextField; }
	public void setMinCpuTextField( JTextField minCpuTextField ){ this.minCpuTextField = minCpuTextField; }
	
	private JTextField maxCpuTextField;
	public JTextField getMaxCpuTextField(){ return maxCpuTextField; }
	public void setMaxCpuTextField( JTextField maxCpuTextField ){ this.maxCpuTextField = maxCpuTextField; }
	
	private JLabel memoryLabel;
	public JLabel getMemoryLabel(){ return memoryLabel; }
	public void setMemoryLabel( JLabel memoryLabel ){ this.memoryLabel = memoryLabel; }
	
	private JTextField minMemoryTextField;
	public JTextField getMinMemoryTextField(){ return minMemoryTextField; }
	public void setMinMemoryTextField( JTextField minMemoryTextField ){ this.minMemoryTextField = minMemoryTextField; }
	
	private JTextField maxMemoryTextField;
	public JTextField getMaxMemoryTextField(){ return maxMemoryTextField; }
	public void setMaxMemoryTextField( JTextField maxMemoryTextField ){ this.maxMemoryTextField = maxMemoryTextField; }
	
	private JLabel diskSpaceLabel;
	public JLabel getDiskSpaceLabel(){ return diskSpaceLabel; }
	public void setDiskSpaceLabel( JLabel diskSpaceLabel ){ this.diskSpaceLabel = diskSpaceLabel; }
	
	private JTextField minDiskSpaceTextField;
	public JTextField getMinDiskSpaceTextField(){ return minDiskSpaceTextField; }
	public void setMinDiskSpaceTextField( JTextField minDiskSpaceTextField ){ this.minDiskSpaceTextField = minDiskSpaceTextField; }
	
	private JTextField maxDiskSpaceTextField;
	public JTextField getMaxDiskSpaceTextField(){ return maxDiskSpaceTextField; }
	public void setMaxDiskSpaceTextField( JTextField maxDiskSpaceTextField ){ this.maxDiskSpaceTextField = maxDiskSpaceTextField; }
	
	private JLabel bandwidthLabel;
	public JLabel getBandwidthLabel(){ return bandwidthLabel; }
	public void setBandwidthLabel( JLabel bandwidthLabel ){ this.bandwidthLabel = bandwidthLabel; }
	
	private JTextField minBandwidthTextField;
	public JTextField getMinBandwidthTextField(){ return minBandwidthTextField; }
	public void setMinBandwidthTextField( JTextField minBandwidthTextField ){ this.minBandwidthTextField = minBandwidthTextField; }
    
	private JTextField maxBandwidthTextField;
	public JTextField getMaxBandwidthTextField(){ return maxBandwidthTextField; }
	public void setMaxBandwidthTextField( JTextField maxBandwidthTextField ){ this.maxBandwidthTextField = maxBandwidthTextField; }

	private JLabel informationLabel;
	public JLabel getInformationLabel(){ return informationLabel; }
	public void setInformationLabel( JLabel informationLabel ){ this.informationLabel = informationLabel; }
	
	public CreateVirtualNetworksSelectPanel()
    {   
    	this.setLayout( new java.awt.BorderLayout() );
        this.add( this.titlePanel(), BorderLayout.NORTH );
        this.add( this.contentPanel(), BorderLayout.CENTER );
    }
	private JPanel titlePanel()
	{
        JLabel titleLabel = new JLabel( "Random virtual networks" );
        titleLabel.setFont( new Font( "MS Sans Serif", Font.BOLD, 14 ) );
        titleLabel.setBorder( new EmptyBorder( new Insets( 10, 10, 10, 10 ) ) );
        titleLabel.setOpaque( true );
        
        JPanel titlePanel = new JPanel();
        titlePanel.setLayout( new java.awt.BorderLayout() );
        titlePanel.setBackground( Color.gray );
        titlePanel.add( titleLabel, BorderLayout.CENTER );
        titlePanel.add( new JSeparator(), BorderLayout.SOUTH );
        
        return titlePanel;
	}
	private JPanel contentPanel()
	{
		JPanel informationPanel = this.informationPanel();
		JPanel networksPanel = this.networksPanel();
		JPanel nodesPanel = this.nodesPanel();
		JPanel linksPanel = this.linksPanel();
		JPanel nodePanel  = this.nodePanel();
		JPanel linkPanel  = this.linkPanel();
		
        JPanel contentPanel = new JPanel();
        
		GroupLayout groupLayout = new GroupLayout( contentPanel );
		groupLayout.setAutoCreateGaps( true );
		groupLayout.setAutoCreateContainerGaps( true );
		groupLayout.setHorizontalGroup( groupLayout.createSequentialGroup().addGroup( groupLayout.createParallelGroup().addComponent( informationPanel ).addComponent( networksPanel ).addComponent( nodesPanel ).addComponent( linksPanel ).addComponent( nodePanel ).addComponent( linkPanel ) ) );
		groupLayout.setVerticalGroup( groupLayout.createParallelGroup().addGroup( groupLayout.createSequentialGroup().addComponent( informationPanel ).addComponent( networksPanel ).addComponent( nodesPanel ).addComponent( linksPanel ).addComponent( nodePanel ).addComponent( linkPanel ) ) );
		contentPanel.setLayout( groupLayout );
        
        return contentPanel;
	}
	
    private JPanel informationPanel()
	{
		this.setInformationLabel( new JLabel() );
		
		JPanel informationPanel = new JPanel();
		informationPanel.add( this.getInformationLabel() );
		
		return informationPanel;
	}
	
	private JPanel networksPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>VIRTUAL NETWORKS</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel networksPanel = new JPanel();
        networksPanel.setLayout( new GridLayout( 0, 1 ) );
        networksPanel.setBorder( titledBorder );
        networksPanel.add( this.networksNumberPanel() );
        networksPanel.add( this.windowTimeUnitsNumberPanel() );
        networksPanel.add( this.poissonArrivesPanel() );
        networksPanel.add( this.exponentialLifetimePanel() );
         
        return networksPanel;
	}
    private JPanel networksNumberPanel()
    {
    	this.setNetworksNumberLabel( new JLabel( "<html><b>Networks number:</b></html>" ) );
    	this.setNetworksNumberTextField( new JTextField( Integer.toString( VirtualNetworksFactory.NETWORKS_NUMBER ) ) );
    	this.getNetworksNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getNetworksNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel networksNumberPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        networksNumberPanel.add( this.getNetworksNumberLabel() );
        networksNumberPanel.add( this.getNetworksNumberTextField() );
        
        return networksNumberPanel;
    }
    private JPanel windowTimeUnitsNumberPanel()
    {
    	this.setWindowTimeUnitsNumberLabel( new JLabel( "<html><b>Window time units number:</b></html>" ) );
    	
    	this.setWindowTimeUnitsNumberTextField( new JTextField( Integer.toString( VirtualNetworksFactory.WINDOW_TIME_UNITS_NUMBER ) ) );
    	this.getWindowTimeUnitsNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getWindowTimeUnitsNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel windowTimeUnitsNumberPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        windowTimeUnitsNumberPanel.add( this.getWindowTimeUnitsNumberLabel() );
        windowTimeUnitsNumberPanel.add( this.getWindowTimeUnitsNumberTextField() );
        
        return windowTimeUnitsNumberPanel;
    }
    private JPanel poissonArrivesPanel()
    {
    	this.setPoissonArrivesLabel( new JLabel( "<html><b>Networks number per window in Poisson arrives:</b></html>" ) );
    	
    	this.setPoissonArrivesTextField( new JTextField( Integer.toString( (int) VirtualNetworksFactory.POISSON_ARRIVES ) ) );
    	this.getPoissonArrivesTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getPoissonArrivesTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel poissonArrivesPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        poissonArrivesPanel.add( this.getPoissonArrivesLabel() );
        poissonArrivesPanel.add( this.getPoissonArrivesTextField() );
                
        return poissonArrivesPanel;
    }
    private JPanel exponentialLifetimePanel()
    {
    	this.setExponentialLifetimeLabel( new JLabel( "<html><b>Average time units of exponential lifetime:</b></html>" ) );
    	
    	this.setExponentialLifetimeTextField( new JTextField( Integer.toString( (int) VirtualNetworksFactory.EXPONENTIAL_LIFETIME ) ) );
    	this.getExponentialLifetimeTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getExponentialLifetimeTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel exponentialLifetimePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        exponentialLifetimePanel.add( this.getExponentialLifetimeLabel() );
        exponentialLifetimePanel.add( this.getExponentialLifetimeTextField() );
        
        return exponentialLifetimePanel;
    }
    
    private JPanel nodesPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>VIRTUAL NODES</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel nodesPanel = new JPanel();
        nodesPanel.setLayout( new GridLayout( 0, 1 ) );
        nodesPanel.setBorder( titledBorder );
        nodesPanel.add( this.nodesNumberRangePanel() );
        nodesPanel.add( this.typesNodePercentagesPanel() );
        nodesPanel.add( this.operatingSystemsPercentagesPanel() );
        nodesPanel.add( this.virtualEnvironmentsPercentagesPanel() );
        
        return nodesPanel;
	}
    private JPanel nodesNumberRangePanel()
    {
    	this.setNodesNumberLabel( new JLabel( "<html><b>Nodes number:</b></html>" ) );
    	
    	this.setMinNodesNumberTextField( new JTextField( Integer.toString( VirtualNetworksFactory.MIN_NODES_NUMBER ) ) );
        this.getMinNodesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMinNodesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
        
        this.setMaxNodesNumberTextField( new JTextField( Integer.toString( VirtualNetworksFactory.MAX_NODES_NUMBER ) ) );
        this.getMaxNodesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMaxNodesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel nodesNumberRangePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	nodesNumberRangePanel.add( this.getNodesNumberLabel() );
    	nodesNumberRangePanel.add( new JLabel( "Between" ) );
    	nodesNumberRangePanel.add( this.getMinNodesNumberTextField() );
        nodesNumberRangePanel.add( new JLabel( "and" ) );
        nodesNumberRangePanel.add( this.getMaxNodesNumberTextField() );
        
        return nodesNumberRangePanel;
    }
    private JPanel typesNodePercentagesPanel()
    {
    	this.setNodeTypesPercentagesLabel( new JLabel( "<html><b>Types %:</b></html>" ) );
    	
    	this.setRoutersPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.ROUTERS_PERCENTAGE ) ) );
    	this.getRoutersPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getRoutersPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setSwitchesPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.SWITCHES_PERCENTAGE ) ) );
    	this.getSwitchesPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getSwitchesPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setServersPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.SERVERS_PERCENTAGE ) ) );
    	this.getServersPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getServersPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel typesNodePercentagesPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	
    	typesNodePercentagesPanel.add( this.getNodeTypesPercentagesLabel() );
    	
    	typesNodePercentagesPanel.add( new JLabel( "Routers:" ) );
    	typesNodePercentagesPanel.add( this.getRoutersPercentageTextField() );
    	
    	typesNodePercentagesPanel.add( new JLabel( "Switches:" ) );
    	typesNodePercentagesPanel.add( this.getSwitchesPercentageTextField() );
    	
    	typesNodePercentagesPanel.add( new JLabel( "Servers:" ) );
    	typesNodePercentagesPanel.add( this.getServersPercentageTextField() );
    	
    	return typesNodePercentagesPanel;
    }
    private JPanel operatingSystemsPercentagesPanel()
    {
    	this.setOperatingSystemsLabel( new JLabel( "<html><b>Operating systems %:</b></html>" ) );
    	
    	this.setLinuxPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.LINUX_PERCENTAGE ) ) );
    	this.getLinuxPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getLinuxPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setWindowsPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.WINDOWS_PERCENTAGE ) ) );
    	this.getWindowsPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getWindowsPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setSolarisPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.SOLARIS_PERCENTAGE ) ) );
    	this.getSolarisPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getSolarisPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setAndroidPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.ANDROID_PERCENTAGE ) ) );
    	this.getAndroidPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getAndroidPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel operatingSystemsPercentagesPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	
    	operatingSystemsPercentagesPanel.add( this.getOperatingSystemsLabel() );
    	
    	operatingSystemsPercentagesPanel.add( new JLabel( "Linux:" ) );
    	operatingSystemsPercentagesPanel.add( this.getLinuxPercentageTextField() );
    	
    	operatingSystemsPercentagesPanel.add( new JLabel( "Windows:" ) );
    	operatingSystemsPercentagesPanel.add( this.getWindowsPercentageTextField() );
    	
    	operatingSystemsPercentagesPanel.add( new JLabel( "Solaris:" ) );
    	operatingSystemsPercentagesPanel.add( this.getSolarisPercentageTextField() );
    	
    	operatingSystemsPercentagesPanel.add( new JLabel( "Android:" ) );
    	operatingSystemsPercentagesPanel.add( this.getAndroidPercentageTextField() );
    	
    	return operatingSystemsPercentagesPanel;
    }
    private JPanel virtualEnvironmentsPercentagesPanel()
    {
    	this.setVirtualEnvironmentsLabel( new JLabel( "<html><b>Virtual environments %:</b></html>" ) );
    	
    	this.setVmWarePercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.VMWARE_PERCENTAGE ) ) );
    	this.getVmWarePercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getVmWarePercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setXenPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.XEN_PERCENTAGE ) ) );
    	this.getXenPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getXenPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setKvmPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.KVM_PERCENTAGE ) ) );
    	this.getKvmPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getKvmPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setUmlPercentageTextField( new JTextField( Integer.toString( VirtualNodesFactory.UML_PERCENTAGE ) ) );
    	this.getUmlPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getUmlPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel virtualEnvironmentsPercentagePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	virtualEnvironmentsPercentagePanel.add( this.getVirtualEnvironmentsLabel() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "VMware:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getVmWarePercentageTextField() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "Xen:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getXenPercentageTextField() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "KVM:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getKvmPercentageTextField() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "UML:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getUmlPercentageTextField() );
    	
    	return virtualEnvironmentsPercentagePanel;
    }
    
    private JPanel linksPanel()
    {
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>VIRTUAL LINKS</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel linksPanel = new JPanel();
        linksPanel.setLayout( new GridLayout( 0, 1 ) );
        linksPanel.setBorder( titledBorder );
        linksPanel.add( this.linksNumberPercentagePanel() );
        linksPanel.add( this.linksNumberRangePanel() );
        linksPanel.add( this.linkTypePercentagesPanel() );
        
    	ButtonGroup linksNumberButtonGroup = new ButtonGroup();
        linksNumberButtonGroup.add( this.getLinksNumberPercentageRadioButton() );
    	linksNumberButtonGroup.add( this.getLinksNumberRangeRadioButton() );
        
        return linksPanel;
    }
    private JPanel linksNumberPercentagePanel()
    {
    	this.setLinksNumberPercentageRadioButton( new JRadioButton( "<html><b>Links number between nodes %:</b></html>"  ) );
    	this.getLinksNumberPercentageRadioButton().setSelected( true );
    	
    	this.setLinksNumberPercentageTextField( new JTextField( Integer.toString( VirtualNetworksFactory.LINKS_NUMBER_PERCENTAGE ) ) );
    	this.getLinksNumberPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getLinksNumberPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.getLinksNumberPercentageTextField().setEnabled( true );
    	
        JPanel linksNumberPercentagePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );        
        linksNumberPercentagePanel.add( this.getLinksNumberPercentageRadioButton() );
        linksNumberPercentagePanel.add( this.getLinksNumberPercentageTextField() );
        
        return linksNumberPercentagePanel;
    }
    private JPanel linksNumberRangePanel()
    {   
    	this.setLinksNumberRangeRadioButton( new JRadioButton( "<html><b>Links number per node:</b></html>" ) );    	
    	this.getLinksNumberRangeRadioButton().setSelected( false );
        
    	this.setMinLinksNumberTextField( new JTextField( Integer.toString( VirtualNetworksFactory.MIN_LINKS_NUMBER_RANGE ) ) );
    	this.getMinLinksNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinLinksNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.getMinLinksNumberTextField().setEnabled( false );
    	
    	this.setMaxLinksNumberTextField( new JTextField( Integer.toString( VirtualNetworksFactory.MAX_LINKS_NUMBER_RANGE ) ) );
    	this.getMaxLinksNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxLinksNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.getMaxLinksNumberTextField().setEnabled( false );
    	
    	JPanel linksNumberRangePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        linksNumberRangePanel.add( this.getLinksNumberRangeRadioButton() );
        linksNumberRangePanel.add( new JLabel( "Between" ) );
        linksNumberRangePanel.add( this.getMinLinksNumberTextField() );
        linksNumberRangePanel.add( new JLabel( "and" ) );
        linksNumberRangePanel.add( this.getMaxLinksNumberTextField() );
    	
    	return linksNumberRangePanel;
    }
    private JPanel linkTypePercentagesPanel()
    {
    	this.setLinkTypesPercentagesLabel( new JLabel( "<html><b>Types %:</b></html>" ) );
    	this.setVlanPercentageTextField( new JTextField( Integer.toString( VirtualLinksFactory.VLANS_PERCENTAGE ) ) );
    	this.getVlanPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getVlanPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setSonetPercentageTextField( new JTextField( Integer.toString( VirtualLinksFactory.SDH_SONET_PERCENTAGE ) ) );
    	this.getSonetPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getSonetPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setEight0211PercentageTextField( new JTextField( Integer.toString( VirtualLinksFactory.EIGHT0211_PERCENTAGE ) ) );
    	this.getEight0211PercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getEight0211PercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel linkTypePercentagesPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	linkTypePercentagesPanel.add( this.getLinkTypesPercentagesLabel() );
    	linkTypePercentagesPanel.add( new JLabel( "Vlan:" ) );
    	linkTypePercentagesPanel.add( this.getVlanPercentageTextField() );
    	linkTypePercentagesPanel.add( new JLabel( "SDH/Sonet:" ) );
    	linkTypePercentagesPanel.add( this.getSonetPercentageTextField() );
    	linkTypePercentagesPanel.add( new JLabel( "802.11:" ) );
    	linkTypePercentagesPanel.add( this.getEight0211PercentageTextField() );
    	
    	return linkTypePercentagesPanel;
    }
    
    private JPanel nodePanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>VIRTUAL NODE</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel nodePanel = new JPanel();
        nodePanel.setLayout( new GridLayout( 0, 1 ) );
        nodePanel.setBorder( titledBorder );
        nodePanel.add( this.cpuPanel() );
        nodePanel.add( this.memoryPanel() );
        nodePanel.add( this.diskSpacePanel() );
        
        return nodePanel;
	}
    private JPanel cpuPanel()
    {
    	this.setCpuLabel( new JLabel( "<html><b>CPU:</b></html>" ) );
    	
    	this.setMinCpuTextField( new JTextField( Integer.toString( VirtualNodesFactory.MIN_CPU ) ) );
    	this.getMinCpuTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinCpuTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxCpuTextField( new JTextField( Integer.toString( VirtualNodesFactory.MAX_CPU ) ) );
    	this.getMaxCpuTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxCpuTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel cpuPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	cpuPanel.add( this.getCpuLabel() );
    	cpuPanel.add( new JLabel( "Between" ) );
    	cpuPanel.add( this.getMinCpuTextField() );
    	cpuPanel.add( new JLabel( "and" ) );
    	cpuPanel.add( this.getMaxCpuTextField() );
    	
    	return cpuPanel;
    }
    private JPanel memoryPanel()
    {
    	this.setMemoryLabel( new JLabel( "<html><b>Memory:</b></html>" ) );
    	
    	this.setMinMemoryTextField( new JTextField( Integer.toString( VirtualNodesFactory.MIN_MEMORY ) ) );
    	this.getMinMemoryTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinMemoryTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxMemoryTextField( new JTextField( Integer.toString( VirtualNodesFactory.MAX_MEMORY ) ) );
    	this.getMaxMemoryTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxMemoryTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel memoryPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	memoryPanel.add( this.getMemoryLabel() );
    	memoryPanel.add( new JLabel( "Between" ) );
    	memoryPanel.add( this.getMinMemoryTextField() );
    	memoryPanel.add( new JLabel( "and" ) );
    	memoryPanel.add( this.getMaxMemoryTextField() );
    	
    	return memoryPanel;
    }
    private JPanel diskSpacePanel()
    {
    	this.setDiskSpaceLabel( new JLabel( "<html><b>Disk space:</b></html>" ) );
    	
    	this.setMinDiskSpaceTextField( new JTextField( Integer.toString( VirtualNodesFactory.MIN_DISK_SPACE ) ) );
    	this.getMinDiskSpaceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinDiskSpaceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxDiskSpaceTextField( new JTextField( Integer.toString( VirtualNodesFactory.MAX_DISK_SPACE ) ) );
    	this.getMaxDiskSpaceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxDiskSpaceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel diskSpacePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	diskSpacePanel.add( this.getDiskSpaceLabel() );
    	diskSpacePanel.add( new JLabel( "Between" ) );
    	diskSpacePanel.add( this.getMinDiskSpaceTextField() );
    	diskSpacePanel.add( new JLabel( "and" ) );
    	diskSpacePanel.add( this.getMaxDiskSpaceTextField() );
    	
    	return diskSpacePanel;
    }
        
    private JPanel linkPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>VIRTUAL LINK</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel linkPanel = new JPanel();
        linkPanel.setLayout( new GridLayout( 0, 1 ) );
        linkPanel.setBorder( titledBorder );
        linkPanel.add( this.bandwidthPanel() );
        
        return linkPanel;
	}
    private JPanel bandwidthPanel()
    {
    	this.setBandwidthLabel( new JLabel( "<html><b>Bandwidth:</b></html>" ) );
    	
    	this.setMinBandwidthTextField( new JTextField( Integer.toString( VirtualLinksFactory.MIN_BANDWIDTH ) ) );
    	this.getMinBandwidthTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBandwidthTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxBandwidthTextField( new JTextField( Integer.toString( VirtualLinksFactory.MAX_BANDWIDTH ) ) );
    	this.getMaxBandwidthTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxBandwidthTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel bandwidthPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        bandwidthPanel.add( this.getBandwidthLabel() );
        bandwidthPanel.add( new JLabel( "Between" ) );
        bandwidthPanel.add( this.getMinBandwidthTextField() );
        bandwidthPanel.add( new JLabel( "and" ) );
        bandwidthPanel.add( this.getMaxBandwidthTextField() );
        
        return bandwidthPanel;
    }
    
	public void addListeners( DocumentListener documentListener, ActionListener actionListener )
	{
		this.getNetworksNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getWindowTimeUnitsNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getPoissonArrivesTextField().getDocument().addDocumentListener( documentListener );
		this.getExponentialLifetimeTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinNodesNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxNodesNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getRoutersPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getSwitchesPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getServersPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getLinuxPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getWindowsPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getSolarisPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getAndroidPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getVmWarePercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getXenPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getKvmPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getUmlPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getLinksNumberRangeRadioButton().addActionListener( actionListener );
		this.getLinksNumberPercentageRadioButton().addActionListener( actionListener );
		
		this.getMinLinksNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxLinksNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getLinksNumberPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getVlanPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getSonetPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getEight0211PercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinCpuTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxCpuTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinMemoryTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxMemoryTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinDiskSpaceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxDiskSpaceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinBandwidthTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxBandwidthTextField().getDocument().addDocumentListener( documentListener );
	}
	    
	public void refreshLinksNumber()
	{
		this.getMinLinksNumberTextField().setEnabled( false );
		this.getMaxLinksNumberTextField().setEnabled( false );
		
		this.getLinksNumberPercentageTextField().setEnabled( false );
		
		if( this.getLinksNumberRangeRadioButton().isSelected() )
		{
			this.getMinLinksNumberTextField().setEnabled( true );
			this.getMaxLinksNumberTextField().setEnabled( true );
		}
		else
		{
			this.getLinksNumberPercentageTextField().setEnabled( true );
		}
	}
		
	public boolean check()
	{
		this.getInformationLabel().setText( "Press \"Next\" to create random virtual networks" );
		this.getInformationLabel().setForeground( Color.BLACK );
		
		if(      !this.checkNetworksNumber() )					return false;
		else if( !this.checkWindowTimeUnitsNumber() )			return false;
		else if( !this.checkPoissonArrives() )					return false;
		else if( !this.checkExponentialLifetime() )				return false;
		else if( !this.checkNodesNumber() )						return false;
		else if( !this.checkTypesNodePercentages() )				return false;
		else if( !this.checkOperatingSystemsPercentages() )		return false;
		else if( !this.checkVirtualEnvironmentsPercentages() )	return false;
		else if( !this.checkCpu() )								return false;
		else if( !this.checkMemory() )							return false;
		else if( !this.checkDiskSpace() )						return false;
		else if( !this.checkLinksNumber() )						return false;
		else if( !this.checkLinkTypesPercentages() )			return false;
		else if( !this.checkBandwidth() )						return false;
		else 													return true;
	}
	
	private boolean checkNetworksNumber()
	{
		int lowestNetworksNumber = 1;
		int highestNetworksNumber = 50;
		
		try
		{
			int networksNumber = Integer.parseInt( this.getNetworksNumberTextField().getText() );
			
			if( !( lowestNetworksNumber <= networksNumber && networksNumber <= highestNetworksNumber ) )
				throw new NumberFormatException();
			
			this.getNetworksNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestNetworksNumber + " and " + highestNetworksNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getNetworksNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	private boolean checkWindowTimeUnitsNumber()
	{	
		int lowestWindowTimeUnitsNumber = 1;
		int highestWindowTimeUnitsNumber = 50;
		
		try
		{
			int windowTimeUnitsNumber = Integer.parseInt( this.getWindowTimeUnitsNumberTextField().getText() );
			
			if( !( lowestWindowTimeUnitsNumber <= windowTimeUnitsNumber && windowTimeUnitsNumber <= highestWindowTimeUnitsNumber ) )
				throw new NumberFormatException();
			
			this.getWindowTimeUnitsNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestWindowTimeUnitsNumber + " and " + highestWindowTimeUnitsNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getWindowTimeUnitsNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	private boolean checkPoissonArrives()
	{
		int lowestPoissonArrives = 1;
		int highestPoissonArrives = 50;
		
		try
		{
			double poissonArrives = Double.parseDouble( this.getPoissonArrivesTextField().getText() );
			
			if( !( lowestPoissonArrives <= poissonArrives && poissonArrives <= highestPoissonArrives ) )
				throw new NumberFormatException();
			
			this.getPoissonArrivesLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestPoissonArrives + " and " + highestPoissonArrives + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getPoissonArrivesLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	private boolean checkExponentialLifetime()
	{
		int lowestExponentialLifetime = 1;
		int highestExponentialLifetime = 50;
		
		try
		{
			double exponentialLifetime = Double.parseDouble( this.getExponentialLifetimeTextField().getText() );
			
			if( !( lowestExponentialLifetime <= exponentialLifetime && exponentialLifetime <= highestExponentialLifetime ) )
				throw new NumberFormatException();
			
			this.getExponentialLifetimeLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestExponentialLifetime + " and " + highestExponentialLifetime + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getExponentialLifetimeLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	
	private boolean checkNodesNumber()
	{
		int lowestMinNodesNumber = 1;
		int highestMaxNodesNumber = 50;
		
		try
		{
			int minNodesNumber = Integer.parseInt( this.getMinNodesNumberTextField().getText() );
			int maxNodesNumber  = Integer.parseInt( this.getMaxNodesNumberTextField().getText() );
			
			if( !( lowestMinNodesNumber <= minNodesNumber && minNodesNumber <= maxNodesNumber && maxNodesNumber <= highestMaxNodesNumber ) )
				throw new NumberFormatException();
			
			this.getNodesNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinNodesNumber + " and maximum value " + highestMaxNodesNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getNodesNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkTypesNodePercentages()
	{	
		try
		{
			int routersPercentage = Integer.parseInt( this.getRoutersPercentageTextField().getText() );
			int switchesPercentage = Integer.parseInt( this.getSwitchesPercentageTextField().getText() );
			int serversPercentage = Integer.parseInt( this.getServersPercentageTextField().getText() );
			
			if( !( 0 <= routersPercentage  && routersPercentage  <= 100 ) || 
				!( 0 <= switchesPercentage && switchesPercentage <= 100 ) ||
				!( 0 <= serversPercentage  && serversPercentage  <= 100 ) || 
				!( routersPercentage + switchesPercentage + serversPercentage == 100 ) )
				throw new NumberFormatException();
			
			this.getNodeTypesPercentagesLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Type of nodes must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getNodeTypesPercentagesLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkOperatingSystemsPercentages()
	{
		try
		{
			int linuxPercentage   = Integer.parseInt( this.getLinuxPercentageTextField().getText() );
			int windowsPercentage = Integer.parseInt( this.getWindowsPercentageTextField().getText() );
			int solarisPercentage = Integer.parseInt( this.getSolarisPercentageTextField().getText() );
			int androidPercentage = Integer.parseInt( this.getAndroidPercentageTextField().getText() );
								
			if( !( 0 <= linuxPercentage   && linuxPercentage   <= 100 ) || 
				!( 0 <= windowsPercentage && windowsPercentage <= 100 ) || 
				!( 0 <= solarisPercentage && solarisPercentage <= 100 ) || 
				!( 0 <= androidPercentage && androidPercentage <= 100 ) || 
				!( linuxPercentage + windowsPercentage + solarisPercentage + androidPercentage == 100 ) )
				throw new NumberFormatException();
			
			this.getOperatingSystemsLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Operating systems of nodes must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getOperatingSystemsLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkVirtualEnvironmentsPercentages()
	{	
		try
		{
			int vmWarePercentage = Integer.parseInt( this.getVmWarePercentageTextField().getText() );
			int xenPercentage    = Integer.parseInt( this.getXenPercentageTextField().getText() );
			int kvmPercentage    = Integer.parseInt( this.getKvmPercentageTextField().getText() );
			int umlPercentage    = Integer.parseInt( this.getUmlPercentageTextField().getText() );
			
			if( !( 0 <= vmWarePercentage && vmWarePercentage <= 100 ) || 
				!( 0 <= xenPercentage && xenPercentage <= 100 ) || 
				!( 0 <= kvmPercentage && kvmPercentage <= 100 ) || 
				!( 0 <= umlPercentage && umlPercentage <= 100 ) || 
				!( vmWarePercentage + xenPercentage + kvmPercentage + umlPercentage == 100 ) )
				throw new NumberFormatException();
			
			this.getVirtualEnvironmentsLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Virtual environments of nodes must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getVirtualEnvironmentsLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    
    private boolean checkLinksNumber()
	{
    	if( this.getLinksNumberRangeRadioButton().isSelected() )
    		return this.checkLinksNumberRange();
			
		else if( this.getLinksNumberPercentageRadioButton().isSelected() )
			return this.checkLinksNumberPercentage();
		
		return true;		
	}
	private boolean checkLinksNumberPercentage()
	{
		int minLinksNumberPercentage =  15;
		int maxLinksNumberPercentage = 100;
		
		try
		{
			int linksNumberPercentage = Integer.parseInt( this.getLinksNumberPercentageTextField().getText() );
			
			if( !( minLinksNumberPercentage <= linksNumberPercentage && linksNumberPercentage <= maxLinksNumberPercentage ) )
				throw new NumberFormatException();
			
			this.getLinksNumberPercentageRadioButton().setForeground( Color.BLACK );
			
			return true;
			
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + minLinksNumberPercentage + " and " + maxLinksNumberPercentage + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getLinksNumberPercentageRadioButton().setForeground( Color.RED );
			
			return false;
		}
	}
	private boolean checkLinksNumberRange()
	{
		int lowestMinLinksNumber = 1;
		int highestMaxLinksNumber = 50;
		
		try
		{
			int minLinksNumber = Integer.parseInt( this.getMinLinksNumberTextField().getText() );
			int maxLinksNumber = Integer.parseInt( this.getMaxLinksNumberTextField().getText() );
			
			if( !( lowestMinLinksNumber <= minLinksNumber && minLinksNumber <= maxLinksNumber && maxLinksNumber <= highestMaxLinksNumber ) )
				throw new NumberFormatException();
			
			this.getLinksNumberRangeRadioButton().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value "+lowestMinLinksNumber+" and maximum value "+highestMaxLinksNumber+"</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getLinksNumberRangeRadioButton().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkLinkTypesPercentages()
	{
		try
		{
			int vlanPercentage = Integer.parseInt( this.getVlanPercentageTextField().getText() );
			int sonetPercentage = Integer.parseInt( this.getSonetPercentageTextField().getText() );
			int eight0211Percentage = Integer.parseInt( this.getEight0211PercentageTextField().getText() );
			
			if( !( 0 <= vlanPercentage  && vlanPercentage  <= 100 ) || 
				!( 0 <= sonetPercentage && sonetPercentage <= 100 ) ||
				!( 0 <= eight0211Percentage  && eight0211Percentage  <= 100 ) || 
				!( vlanPercentage + sonetPercentage + eight0211Percentage == 100 ) )
				throw new NumberFormatException();
			
			this.getLinkTypesPercentagesLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Type of links must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getLinkTypesPercentagesLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	
    private boolean checkCpu()
    {
    	int lowestMinCpu = 0;
    	int highestMaxCpu = 100;
    	
		try
		{
			int minCpu = Integer.parseInt( this.getMinCpuTextField().getText() );
			int maxCpu = Integer.parseInt( this.getMaxCpuTextField().getText() );
			
			if( !( lowestMinCpu <= minCpu && minCpu <= maxCpu && maxCpu <= highestMaxCpu ) )
				throw new NumberFormatException();
			
			this.getCpuLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinCpu + " and maximum value " + highestMaxCpu + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getCpuLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkMemory()
    {
    	int lowestMinMemory = 0;
    	int highestMaxMemory = 100;
    	
		try
		{
			int minMemory = Integer.parseInt( this.getMinMemoryTextField().getText() );
			int maxMemory = Integer.parseInt( this.getMaxMemoryTextField().getText() );
			
			if( !( lowestMinMemory <= minMemory && minMemory <= maxMemory && maxMemory <= 100 ) )
				throw new NumberFormatException();
			
			this.getMemoryLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinMemory + " and maximum value " + highestMaxMemory + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getMemoryLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkDiskSpace()
    {
    	int lowestMinDiskSpace = 0;
    	int highestMaxDiskSpace = 100;
    	
		try
		{
			int minDiskSpace = Integer.parseInt( this.getMinDiskSpaceTextField().getText() );
			int maxDiskSpace = Integer.parseInt( this.getMaxDiskSpaceTextField().getText() );
			
			if( !( lowestMinDiskSpace <= minDiskSpace && minDiskSpace <= maxDiskSpace && maxDiskSpace <= highestMaxDiskSpace ) )
				throw new NumberFormatException();
			
			this.getDiskSpaceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinDiskSpace + " and maximum value " + highestMaxDiskSpace + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getDiskSpaceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
	
    private boolean checkBandwidth()
	{
    	int lowestMinBandwidth = 0;
    	int highestMaxBandwidth = 100;
    	
		try
		{
			int minBandwidth = Integer.parseInt( this.getMinBandwidthTextField().getText() );
			int maxBandwidth = Integer.parseInt( this.getMaxBandwidthTextField().getText() );
			
			if( !( lowestMinBandwidth <= minBandwidth && minBandwidth <= maxBandwidth && maxBandwidth <= highestMaxBandwidth ) )
				throw new NumberFormatException();
			
			this.getBandwidthLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinBandwidth + " and maximum value " + highestMaxBandwidth + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getBandwidthLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	
}
